package gui.initiatives;

import gui.DateTimePanel;
import gui.EarthPanel;

import javax.swing.Timer;

import simulation.initiatives.EngineBuffer;

import common.Buffer;
import common.Constants;
import common.SimulationSettings;

public class ClockControlBuffer extends AbstractClockControl {
  private static final long serialVersionUID = -5822023900023271362L;
    
  private DateTimePanel pnlDateTime;
  private EarthPanel pnlEarth;
  private ClockBufferListener clockUpdater;
  private Timer dateTimeClock;
  private EngineBuffer engine;
  
  public ClockControlBuffer(Buffer buffer, SimulationSettings settings) {
    super(settings);
    engine = new EngineBuffer(buffer, settings);
    clockUpdater = new ClockBufferListener(pnlDateTime, pnlEarth, buffer);
    dateTimeClock = new Timer(Constants.DEFAULT_DISPLAY_RATE, clockUpdater); 
  }
  
  public void adjustDisplayRate(int newRate) {
    dateTimeClock.setDelay(newRate);
  }
    
  public void startClock() {
    engine.start();
  }
  
  public void pauseClock() {
    engine.pause();
  }
  
  public void resetClock() {
    engine.reset();
  }
  
}
